home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc / OpenDoc Development / Debugging Support / OpenDoc™ Source Code / UI / IdleList.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-28  |  4.9 KB  |  184 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        IdleList.h
  3.  
  4.     Contains:    Interface to IdleInfo, IdleList and IdleListIterator classes.
  5.  
  6.     Owned by:    Christopher Linn
  7.  
  8.     Copyright:    © 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <2>     6/14/96    CSL        1257735: Can't register for idle time
  13.                                     during idle time
  14.          <6>     5/25/95    jpa        List.h --> LinkList.h [1253324]
  15.          <5>      4/4/95    RR        1228161 Pass ev to SetIdleFreq
  16.          <4>     1/31/95    RR        # 1206909 Pass ev to
  17.                                     RemoveUnregisteredIdlers
  18.          <3>     9/30/94    RR        #1167950 Allow unregistering while idling
  19.          <2>     9/20/94    RR        Added ev parameter to AddIdle and
  20.                                     RemoveIdle. #1154046 Moved ref counting
  21.                                     into IdleList methods so that an
  22.                                     unregistered part is not released.
  23.          <1>     5/13/94    RR        first checked in
  24.          <5>     3/15/94    MB        Changes to support SCpp/ASLM builds,
  25.                                     #1150864.
  26.          <4>      2/9/94    NP        Tiger Team cleanup.
  27.          <3>     1/26/94    RR        Include ODTypes
  28.          <2>    12/20/93    RR        interface takes part/frame pairs rather
  29.                                     than frames
  30.          <1>    11/16/93    RR        first checked in
  31.  
  32.     To Do:
  33.     In Progress:
  34. */
  35.  
  36. #ifndef _IDLELIST_
  37. #define _IDLELIST_
  38.  
  39. #ifndef _ODTYPES_
  40. #include "ODTypes.h"
  41. #endif
  42.  
  43. #ifndef _PLFMDEF_
  44. #include "PlfmDef.h"
  45. #endif
  46.  
  47. #ifndef _LINKLIST_
  48. #include <LinkList.h>
  49. #endif
  50.  
  51. //==============================================================================
  52. // Theory of Operation
  53. //==============================================================================
  54.  
  55. //==============================================================================
  56. // Scalar Types
  57. //==============================================================================
  58.  
  59. typedef ODULong ODTicks; 
  60.  
  61. //=====================================================================================
  62. // Classes defined in this interface
  63. //=====================================================================================
  64.  
  65. class IdleInfo; 
  66. class IdleList;                
  67. class IdleListIterator;                
  68.  
  69. //=====================================================================================
  70. // Classes used by this interface
  71. //=====================================================================================
  72.  
  73. class ODFrame;
  74. class ODPart;
  75.  
  76. //=====================================================================================
  77. // Global Variables
  78. //=====================================================================================
  79.  
  80. //======================================================================================
  81. // Class IdleInfo
  82. //======================================================================================
  83.  
  84. class IdleInfo : public Link
  85. {
  86. public:
  87.     IdleInfo(ODPart* part, ODFrame* frame, ODIdleFrequency frequency);
  88.     virtual ~IdleInfo();
  89.  
  90.     ODBoolean NeedsIdle(ODTicks ticks);
  91.     ODTicks NextIdle(ODTicks ticks);
  92.     
  93.     ODPart* GetPart() { return fPart; }
  94.     ODFrame* GetFrame() { return fFrame; }
  95.     ODIdleFrequency GetIdleFrequency() { return fIdleFrequency; }
  96.     void SetIdleFrequency(ODIdleFrequency frequency) { fIdleFrequency = frequency; }
  97.     ODTicks GetLastIdle() { return fLastIdle; }
  98.     void SetLastIdle(ODTicks lastIdle) { fLastIdle = lastIdle; }
  99.     ODBoolean ShouldRemove() { return fRemove; }
  100.     void SetShouldRemove(ODBoolean shouldRemove) { fRemove = shouldRemove; }
  101.  
  102. private:    
  103.     ODPart*            fPart;
  104.     ODFrame*         fFrame;
  105.     ODIdleFrequency fIdleFrequency;
  106.     ODTicks         fLastIdle;
  107.     ODBoolean        fRemove;
  108. };
  109.  
  110. //=====================================================================================
  111. // IdleList
  112. //=====================================================================================
  113.  
  114. class IdleList
  115. {
  116.     friend class IdleListIterator;
  117.     
  118. public:
  119.     IdleList();
  120.     virtual ~IdleList();
  121.     
  122.     void AddIdle(Environment* ev, ODPart* part, ODFrame* frame, ODIdleFrequency frequency); 
  123.     
  124.     void RemoveIdle(Environment* ev, ODPart* part, ODFrame* frame); 
  125.     
  126.     void SetIdleFrequency(Environment* ev, ODPart* part, ODFrame* frame, ODIdleFrequency frequency); 
  127.  
  128.     void IterationBegin();
  129.  
  130.     void IterationEnd();
  131.     
  132.     ODIdleFrequency GetMinIdleFrequency();
  133.     
  134. private:
  135.     void RemoveDeferredIdlers();
  136.     
  137.     void AddDeferredIdlers();
  138.  
  139.     ODBoolean FindIdler(Environment* ev, ODPart* part, ODFrame* frame, IdleInfo **idler);
  140.  
  141.     LinkedList     fImplementation;
  142.     ODUShort    fIteratorCount;
  143.     LinkedList    fDeferredAddedIdlers;
  144.     ODIdleFrequency    fMinIdleFrequency;
  145.     ODBoolean    fMinIdleIsInvalid;
  146. };
  147.  
  148. //=====================================================================================
  149. // IdleListIterator
  150. //=====================================================================================
  151.  
  152. class IdleListIterator
  153. {
  154. public:
  155.  
  156.     IdleListIterator(IdleList* idleList);
  157.     
  158.         // Constructor
  159.         
  160.     ODVMethod ~IdleListIterator();
  161.     
  162.         // Destructor
  163.     
  164.     ODMethod IdleInfo* First();
  165.     
  166.         // Returns the first element of the set
  167.         
  168.     ODMethod IdleInfo* Next();
  169.     
  170.         // Returns the next element in the set
  171.         
  172.     ODMethod ODBoolean IsNotComplete();
  173.     
  174.         // Returns TRUE as long as there are more elements in the set
  175.     
  176. private:
  177.     
  178.     LinkedListIterator    fIterator;
  179.     IdleList*            fIdleList;
  180.     
  181. };
  182.  
  183. #endif // _IDLELIST_
  184.